#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<unordered_set>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
void solve()
{
     int ans ; 
     int n,m;
     cin >> n >> m;
     if(m >= 8) ans = (n - 2016) * 12 + (m - 8) + 1;
     else ans =  (n - 2016 - 1) * 12 + 5 + m;
     cout << ans << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t = 1;
    while(t--) solve();
    return 0;
}